home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ASME's Mechanical Engine…ing Toolkit 1997 December
/
ASME's Mechanical Engineering Toolkit 1997 December.iso
/
auto_cad
/
faceit.lsp
< prev
next >
Wrap
Text File
|
1989-10-14
|
3KB
|
53 lines
;FACEIT.LSP Bill Enger
;1/18/89 Replaces a selected 3D Polygon Mesh entity with a similar
; coating of 3DFACE entites, which have invisible interior edges.
; Intended for use on entities generated by "RULESURF", which do
; not allow making their interior edges invisible. User must erase
; the 3D mesh afterwards, or add that capability to the code.
(defun c:faceit ()
(princ "Select a 3D Polygon Mesh: ") ; generated by "rulesurf"
(setq PLINE (car (entsel)))
(command "ucs" "w") ; switch to WCS
(setq ELIST (entget PLINE))
(while (not (and (eq (cdr (assoc 0 ELIST)) "POLYLINE") ; "until user
(eq (cdr (assoc 70 ELIST)) 16))) ; gets it right"
(princ "This only works on 3D POLYGON MESH entities. Try again...")
(setq PLINE (car (entsel)))
(setq ELIST (entget PLINE)))
(setq N (getvar "SURFTAB1") ; get number of edges in N direction
VL1 () ; empty lists for vertices in
VL2 ()) ; N direction
(setq ENAME (entnext PLINE)) ; first vertex subentity
(repeat (1+ N) ; for all vertices on "side 1"
(setq ELIST (entget ENAME))
(setq VL1 (cons (cdr (assoc 10 ELIST)) VL1)) ; put coord list into list 1
(setq ENAME (entnext ENAME))) ; next vertex
(repeat (1+ N) ; for all vertices on "side 2"
(setq ELIST (entget ENAME))
(setq VL2 (cons (cdr (assoc 10 ELIST)) VL2)) ; put coord list into list 2
(setq ENAME (entnext ENAME))) ; next vertex
(while (nth 1 VL1) ; while there are two vertices left in
(cond ; list 1
((equal (nth 0 VL1) (nth 1 VL1)) ; test if it's a triangle with two
(setq P1 (nth 0 VL1) ; vertices on side 1
P2 (nth 0 VL2)
P3 (nth 1 VL2))
(command "3DFACE" "I" P1 P2 "I" P3 "" "")) ; make a 3 sided 3Dface
((equal (nth 0 VL2) (nth 1 VL2)) ; test if it's a triangle with two
(setq P1 (nth 0 VL2) ; vertices on side 2
P2 (nth 0 VL1)
P3 (nth 1 VL1))
(command "3DFACE" "I" P1 P2 "I" P3 "" "")) ; make a 3 sided 3Dface
(T ; it's a quadrilateral
(setq P1 (nth 0 VL1)
P2 (nth 1 VL1)
P3 (nth 0 VL2)
P4 (nth 1 VL2))
(command "3DFACE" P1 "I" P2 P4 "I" P3 ""))) ; make a 4 sided 3Dface
(setq VL1 (cdr VL1)) ; remove the first vertex from list 1
(setq VL2 (cdr VL2))) ; and from list 2
(command "ucs" "p") return to previous UCS
(princ))